#ifndef _USER_HANDLER_H_
#define _USER_HANDLER_H_

#include "bkshandler.h"
#include "global_def.h"
#include "eventtype.h"
#include "event_def.h"
#include "logger.h"
#include "dispatchtaskservice.h"
#include "sqlconn_pool.h"

#include <map>
#include <mutex>
#include <shared_mutex>

class UserHandler : public BKSHandler{
public:
    UserHandler(std::shared_ptr<ConnPool> &pro_ptr); 

    virtual ~UserHandler();

    virtual BKSEvent*handle(BKSEvent *ev);

private:
    MobileCodeRspEv *handle_mobile_get_code_req(MobileCodeReqEv *ev);
    LoginRspEv *handle_login_req(LoginReqEv *ev);
    i32 generateicode();

private:
    std::map<std::string, i32> _mobile_code_Map;
    std::shared_ptr<ConnPool> pro_ptr;
    std::string _mobile;
    DispatchTaskService *_DTS;
    std::mutex m;
    std::shared_mutex _m;
};

#endif